
/*
    帧表
 */
public class FrameTable {
    //帧大小
    private int frameSize;
    //内存空间的bitmap
    private boolean[] bitMap;
    //帧表
    private FrameTableUnit[] frameTable;

    FrameTable(int frameSize) {
        this.frameSize = frameSize;
        bitMap = new boolean[frameSize];
        this.frameTable = new FrameTableUnit[frameSize];
        for (FrameTableUnit f : frameTable) {
            f = new FrameTableUnit();
        }
    }

    public void addNewLinkToFrameTable(int processID, int pageNum, int frameNum) {
        bitMap[frameNum] = true;
        this.frameTable[frameNum].addNewLink(processID, pageNum);
    }

    public void removeLinkToFrameTable(Process process, int pageNum, int frameNum) {
        if (!bitMap[frameNum])
            return;
        bitMap[frameNum] = frameTable[frameNum].removeLink(process, pageNum);
    }

    public int getFrameSize() {
        return frameSize;
    }

    public boolean[] getBitMap() {
        return bitMap;
    }

    public FrameTableUnit[] getFrameTable() {
        return frameTable;
    }
}
